﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Expression.Shapes;
using System.Windows.Media.Imaging;

namespace WeiTalk.Controls
{
    public partial class PullAndDownControl : UserControl
    {
        bool ready = false;
        bool busy = false;

        public PullAndDownControl()
        {
            InitializeComponent();
        }

        public bool Ready
        {
            get
            {
                return ready;
            }
            set
            {
                if (!Busy)
                {
                    if (value)
                    {
                        ArrowAnimation.To = 180.0;
                        sbArrowReady.Begin();
                    }
                    else
                    {
                        ArrowAnimation.To = 0.0;
                        sbArrowReady.Begin();
                    }
                }
                ready = value;
            }
        }

        public bool Busy
        {
            get { return busy; }
            set
            {
                Loading.IsIndeterminate = value;
                if (value)
                {
                    Loading.Visibility = System.Windows.Visibility.Visible;
                    arrow.Source = new BitmapImage(new Uri("/Images/appbar.refresh.rest.png", UriKind.Relative));
                }
                else
                {
                    Loading.Visibility = System.Windows.Visibility.Collapsed;
                    arrow.Source = new BitmapImage(new Uri("/Images/arrow.png", UriKind.Relative));
                }
                busy = value;
            }
        }

        public bool EnableImage
        {
            set
            {
                if (value)
                {
                    arrow.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    arrow.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
        }

        public string Text
        {
            get
            {
                return this.TextBlock.Text;
            }
            set
            {
                this.TextBlock.Text = value;
            }
        }

    }
}
